/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUI.java
 *
 * Created on 19/03/2011, 21:13:05
 */
package jnlpc.gui;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import jnlpc.prop;
import jnlpc.utils.Filtro;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;

/**
 *
 * @author Zaraki Kenpachi
 */
public class GUI extends javax.swing.JFrame {

    private JFileChooser fc = new JFileChooser();
    private DefaultListModel modelo = new DefaultListModel();
    private ArrayList<prop> prop_sistema = new ArrayList<prop>();

    /** Creates new form GUI */
    public GUI() {
        initComponents();
        this.setLocationRelativeTo(null);
        listapropriedade.setModel(modelo);
        prop_sistema.clear();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jPopupMenu1 = new javax.swing.JPopupMenu();
        checkval = new javax.swing.JMenuItem();
        delete = new javax.swing.JMenuItem();
        painel = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        versao = new javax.swing.JTextField();
        urldabase = new javax.swing.JTextField();
        OK = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        off = new javax.swing.JCheckBox();
        titulo = new javax.swing.JTextField();
        empresa = new javax.swing.JTextField();
        homepage = new javax.swing.JTextField();
        descricao = new javax.swing.JTextField();
        icone = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        arquivojar = new javax.swing.JTextField();
        versaodojava = new javax.swing.JTextField();
        propriedade = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        classeprincipal = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        listapropriedade = new javax.swing.JList();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        checkval.setText("Checar Valor");
        checkval.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkvalActionPerformed(evt);
            }
        });
        jPopupMenu1.add(checkval);

        delete.setText("Deletar");
        delete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteActionPerformed(evt);
            }
        });
        jPopupMenu1.add(delete);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("JNLP Creator");
        setResizable(false);

        jLabel1.setText("Versão:");

        jLabel2.setText("URL:");

        OK.setText("Gerar JNLP");
        OK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OKActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(urldabase)
                            .addComponent(versao, javax.swing.GroupLayout.PREFERRED_SIZE, 348, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(171, 171, 171)
                        .addComponent(OK)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(52, 52, 52)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(versao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(urldabase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 157, Short.MAX_VALUE)
                .addComponent(OK)
                .addGap(26, 26, 26))
        );

        painel.addTab("JNLP", jPanel1);
        jPanel1.getAccessibleContext().setAccessibleName("tab1");

        jLabel3.setText("Titulo:");

        jLabel4.setText("Quem publica:");

        jLabel5.setText("Site:");

        jLabel6.setText("Descrição:");

        jLabel7.setText("Icone:");

        off.setText("Permitir execução offline");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7))
                        .addGap(34, 34, 34)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(descricao, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
                            .addComponent(homepage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
                            .addComponent(empresa, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
                            .addComponent(titulo, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
                            .addComponent(icone, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)))
                    .addComponent(off))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(27, 27, 27)
                        .addComponent(jLabel4)
                        .addGap(33, 33, 33)
                        .addComponent(jLabel5)
                        .addGap(52, 52, 52)
                        .addComponent(jLabel6)
                        .addGap(47, 47, 47)
                        .addComponent(jLabel7))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(titulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(empresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(homepage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(34, 34, 34)
                        .addComponent(descricao, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(28, 28, 28)
                        .addComponent(icone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(off)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        painel.addTab("Informações", jPanel3);

        jLabel8.setText("Arquivo JAR:");

        jLabel9.setText("Versão do java:");

        jLabel10.setText("Propriedades do Sistema:");

        propriedade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                propriedadeKeyPressed(evt);
            }
        });

        jLabel11.setText("Classe Principal:");

        listapropriedade.setComponentPopupMenu(jPopupMenu1);
        jScrollPane1.setViewportView(listapropriedade);

        jButton1.setText("Add");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Del");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel9))
                                .addGap(64, 64, 64)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(versaodojava, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
                                    .addComponent(arquivojar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addGap(63, 63, 63)
                                .addComponent(classeprincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addGap(28, 28, 28)
                                .addComponent(propriedade, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)))
                        .addGap(28, 28, 28)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jButton2, 0, 0, Short.MAX_VALUE)
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(arquivojar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(versaodojava, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(classeprincipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(propriedade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        painel.addTab("Resource", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painel, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painel, javax.swing.GroupLayout.PREFERRED_SIZE, 344, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        painel.getAccessibleContext().setAccessibleName("asd");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private boolean checar() {
        if (arquivojar.getText().isEmpty() || classeprincipal.getText().isEmpty() || descricao.getText().isEmpty() || empresa.getText().isEmpty() || homepage.getText().isEmpty() || urldabase.getText().isEmpty() || versao.getText().isEmpty() || versaodojava.getText().isEmpty() || titulo.getText().isEmpty()) {
            return false;
        } else {
            return true;
        }
    }

    private void OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OKActionPerformed

        modelo.addElement("XD");
        if (checar()) {
            Element jnlp = new Element("jnlp");
            Element information = new Element("information");
            Element resources = new Element("resources");
            Element appdesc = new Element("application-desc");
            Element title = new Element("title");
            Element vendor = new Element("vendor");
            Element description = new Element("description");
            Element offline = new Element("offline-allowed");
            Element j2se = new Element("j2se");
            Element jar = new Element("jar");
            Element icon = new Element("icon");
            Element homepage = new Element("homepage");

            jnlp.setAttribute("spec", versao.getText());
            jnlp.setAttribute("codebase", urldabase.getText());

            title.setText(titulo.getText());
            vendor.setText(empresa.getText());
            description.setText(descricao.getText());
            j2se.setAttribute("version", versaodojava.getText());
            jar.setAttribute("href", arquivojar.getText());
            appdesc.setAttribute("main-class", classeprincipal.getText());

            if (!icone.getText().isEmpty()) {
                icon.setAttribute("href", icone.getText());
            }

            jnlp.addContent(information);
            jnlp.addContent(resources);
            jnlp.addContent(appdesc);

            information.addContent(title);
            information.addContent(vendor);
            information.addContent(description);

            if (off.isSelected()) {
                information.addContent(offline);
            }

            resources.addContent(j2se);
            resources.addContent(jar);

            for (int i = 0; i < prop_sistema.size(); i++) {
                appdesc.setAttribute(prop_sistema.get(i).getPropriedade(), prop_sistema.get(i).getValue());
            }


            Document doc = new Document(jnlp);
            doc.setRootElement(jnlp);

            XMLOutputter xout = new XMLOutputter();

            fc.setDialogTitle("Digite o nome do arquivo a ser salvo");
            fc.setDialogType(JFileChooser.SAVE_DIALOG);
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fc.setFileFilter(new Filtro(".jnlp", "Arquivos JNLP"));
            fc.showDialog(null, "Salvar");

            System.out.println(off.isSelected());
            if (!fc.getSelectedFile().exists()) {
                FileOutputStream f = null;
                boolean fail = false;
                try {
                    f = new FileOutputStream(new File(fc.getSelectedFile().getAbsolutePath() + ".jnlp"));
                    xout.output(doc, f);
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    fail = true;
                } catch (IOException ex) {
                    Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    fail = true;
                } finally {
                    try {
                        f.close();
                    } catch (IOException ex) {
                        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }

                if (fail) {
                    JOptionPane.showMessageDialog(null, "Erro ao gravar arquivo");
                }
            }

        } else {
            JOptionPane.showMessageDialog(null, "Preencha todos os campos antes de gerar o arquivo!");
        }
    }//GEN-LAST:event_OKActionPerformed

    private void adicionar() {
        if (!propriedade.getText().isEmpty()) {
            boolean find = false;
            String[] s = propriedade.getText().split(";");
            prop tmp;
            if (s.length == 2) {
                if (prop_sistema.isEmpty()) {
                    tmp = new prop();
                    tmp.setPropriedade(s[0].replace(" ", ""));
                    tmp.setValue(s[1].replace(" ", ""));
                    prop_sistema.add(tmp);
                    modelo.addElement(tmp.getPropriedade());
                    propriedade.setText("");
                } else {
                    for (int j = 0; j < prop_sistema.size(); j++) {
                        if (s[0].replace(" ", "").equalsIgnoreCase(prop_sistema.get(j).getPropriedade())) {
                            find = true;
                        }
                    }
                    if (find) {
                        JOptionPane.showMessageDialog(null, "Uma propriedade com esse nome já existe!");
                    } else {
                        tmp = new prop();
                        tmp.setPropriedade(s[0].replace(" ", ""));
                        tmp.setValue(s[1].replace(" ", ""));
                        prop_sistema.add(tmp);
                        modelo.addElement(tmp.getPropriedade());
                        propriedade.setText("");
                    }
                }
            } else {
                JOptionPane.showMessageDialog(null, "Propriedade Invalida");
            }
        }

    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        adicionar();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void deletar() {
        if (!listapropriedade.isSelectionEmpty()) {
            int pos = listapropriedade.getSelectedIndex();
            modelo.remove(pos);
            prop_sistema.remove(pos);
        }
    }

    private void checkvalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkvalActionPerformed
        // TODO add your handling code here:
        if (prop_sistema.size() > 0) {
            JOptionPane.showMessageDialog(null, "O Valor dessa propriedade é: " + prop_sistema.get(listapropriedade.getSelectedIndex()).getValue());
        }
    }//GEN-LAST:event_checkvalActionPerformed

    private void propriedadeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_propriedadeKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == 10) {
            adicionar();
        }

    }//GEN-LAST:event_propriedadeKeyPressed

    private void deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteActionPerformed
        // TODO add your handling code here:
        deletar();
    }//GEN-LAST:event_deleteActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        deletar();
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable()                    {

            public void run() {
                new GUI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton OK;
    private javax.swing.JTextField arquivojar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JMenuItem checkval;
    private javax.swing.JTextField classeprincipal;
    private javax.swing.JMenuItem delete;
    private javax.swing.JTextField descricao;
    private javax.swing.JTextField empresa;
    private javax.swing.JTextField homepage;
    private javax.swing.JTextField icone;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JList listapropriedade;
    private javax.swing.JCheckBox off;
    private javax.swing.JTabbedPane painel;
    private javax.swing.JTextField propriedade;
    private javax.swing.JTextField titulo;
    private javax.swing.JTextField urldabase;
    private javax.swing.JTextField versao;
    private javax.swing.JTextField versaodojava;
    // End of variables declaration//GEN-END:variables
}
